import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import Mine from '../views/mine.vue'
import Contact from '../views/Contact.vue'
var link=window.location.href;
console.log(link)
var arr=link.split('/');
arr.pop();
console.log(arr)
arr.shift()
arr.shift()
arr.shift()
link=arr.join('/');
console.log(link)
//此路由为home页专用，设置默认路由到首页
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  mode:'hash',
  routes: [
    {
      // 首页
      path: '/'+link+'/home',
      component: HomeView
    },
    {
      path: '/'+link+'/contact',
      component:Contact
    },{
      path: "/"+link+'/mine',
      component:Mine
    },{
      path:'/:path(.*)',
      component:HomeView
    }
  ]
})

export default router
